<template>
  <fieldset>
    <legend>混入</legend>
    <h1>{{ msg }}</h1>
    <h1>{{ age }}</h1>
    <button @click="handleClick">点击</button>
  </fieldset>
</template>
<script>
let mixObj = {
  data() {
    return {
      msg: "混入对象的msg",
      age: 34,
    };
  },
  methods: {
    handleClick() {
      console.log("混入对象的handleClick");
    },
    log() {
      alert("混入对象的log");
    },
  },
  mounted() {
    console.log("这是混入对象的mounted");
  },
};

export default {
  mixins: [mixObj],
  data() {
    return {
      msg: "组件选项",
    };
  },
  methods: {
    handleClick() {
      console.log("混入组件的方法");
    },
  },
  mounted() {
    console.log("这是组件的mounted钩子函数");
  },
};
</script>
